<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

$THEME->addBreadcrumb($this->adminUrl.'/domains/root/', $this->lang('ap_title_domains_default'));


if(Antz_IntelliForm::submitted('default-domain')){
    $id = (int) post('domain');

    if($DB->countRows($CONFIG->dbprefix.'domains', "id = '{$id}'")==0){
        JFX::addError($this->lang('invalid_domain_for_default'));
        return;
    }

    $DB->query("UPDATE {$CONFIG->dbprefix}domains SET is_default = 0");
    $DB->update($CONFIG->dbprefix.'domains', array('is_default'=>1), "id = '{$id}'");

    JFX::addSuccess($this->lang('default_domain_success'));
    JFX::redirect(THIS_PAGE_URL);

}




$defaultFormFields = array(
    array(
        'name' => 'domain',
        'type' => 'select',
        'label' => $this->lang('domain'),
        'options' => $domainOpts,
        'value' => post('domain', $CONFIG->domainid)
    ),
    array(
        'name' => 'submitBtn',
        'type' => 'submit',
        'value' => $this->lang('set_default_domain_submit'),
        'label' => '&nbsp;'
    )
);

$defaultForm = JFX::makeRapidForm($defaultFormFields, $this->lang('set_default_domain_legend'), 'default-domain');

echo '<div id="jfx-default-domain">'.$defaultForm->render().'</div>';
echo '<div class="jfx-clear"></div>';





